package com.qi.demo01.Lock8;

/**
 * @author zjq
 * @date 2020/3/31 19:43
 * <p>
 * synchronized是可重入锁
 */
public class ReentrantLock_Sny {
    //可重入锁 sync
    public static void main(String[] args) {
        phone p = new phone();
        new Thread(() -> {
            p.sms();
        }, "t1").start();

        new Thread(() -> {

            p.sms();
        }, "t2").start();
    }
}

class phone {
    public synchronized void sms() {
        System.out.println(Thread.currentThread().getName() + "==>sms");
        call();//这里也有锁
    }

    public synchronized void call() {
        System.out.println(Thread.currentThread().getName() + "==>call");
        System.out.println("***************************");
    }
}